package com.bawei.database.db

import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RenameTable
import androidx.room.RoomDatabase
import androidx.room.TypeConverter
import androidx.room.migration.AutoMigrationSpec
import com.bawei.database.dao.VideoDao
import com.bawei.database.table.VideoEntity

/**
 * Author: Jason Zhang
 * Date: 2024/4/24
 * Desc: 数据库
 */

@Database(
    entities = [VideoEntity::class], //数据库中表格实体对象数组，可以设置多个对象
    version = 2, //当前数据库版本号
    exportSchema = false, //是否导出数据库结构
//    autoMigrations = [
//        AutoMigration(
//            from = 1,
//            to = 2,
//            spec = AppDataBase.VideoAutoMigration::class) //@DeleteTable, @RenameTable, @DeleteColumn @RenameColumn
//    ] //数据库自动升级
)
abstract class AppDataBase : RoomDatabase() {
    //获取视频数据表操作对象
    abstract fun getVideoDao(): VideoDao

    /**
     * 修改视频表名称
     */
    @RenameTable(fromTableName =  "video_table", toTableName = "new_video_table")
    class VideoAutoMigration: AutoMigrationSpec


}